/*
 * @Author: your name
 * @Date: 2021-09-27 16:53:06
 * @LastEditTime: 2021-09-27 16:53:07
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /egg-ts-template/app/model/test.ts
 */
// app/model/User.ts
import { Application } from 'egg';

export default function(app: Application) {
  const { STRING, INTEGER, BIGINT } = app.Sequelize;
  const User = app.model.define('user', {
    id: {
      autoIncrement: true,
      type: INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: '用户id',
    },
    username: {
      type: STRING(55),
      allowNull: true,
      comment: '用户名',
      unique: 'username',
    },
    password: {
      type: STRING(55),
      allowNull: true,
      comment: '用户密码',
    },
    phone: {
      type: BIGINT,
      allowNull: true,
      comment: '手机号',
    },
    user_img: {
      type: STRING(120),
      allowNull: true,
      comment: '用户头像',
    },
    status: {
      type: INTEGER,
      allowNull: true,
      defaultValue: 1,
      comment: '0:不可用,1:可用',
    },
    profile: {
      type: STRING(255),
      allowNull: true,
      comment: '个人简介',
    },
    email: {
      type: STRING(255),
      allowNull: true,
      comment: '电子邮箱',
    },
    email_password: {
      type: STRING(255),
      allowNull: true,
      comment: '电子邮箱密码',
    },
  }, {
    freezeTableName: true,
  });
  return User;
}
